﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="jquery-1.10.2.min.js"></script>
    <script src="knockout-3.0.0.js"></script>
    <script src="ViewModel.js"></script>
    
</head>
<body>
<div>
    <label>名字</label><input data-bind="value:Name"/>
    <label>姓名</label><input data-bind="value:FullName"/>
    <input type="button" value="确定" data-bind="click:format"/>
</div>

</body>


</html>
<script type="text/javascript" language="javascript">
    function TestModel() {
        var self = this;
        self.Name = ko.observable("Name");
        self.FullName = ko.observable();
        self.format = function () {
            if (self.Name()) {
                var address = "yang" + self.Name();
                self.FullName(address);
            } else {
                alert("输入");
            }
        };
        self.format();
    }

    ko.applyBindings(new TestModel());
</script>